This notebook explores likes vs retweets.
# Read in the scraped_tweets data
import pandas as pd
df = pd.read_csv('../data/scraped_tweets/single cell sequencing OR single-cell sequencing.csv', lineterminator='\n')
# Filter by at least 10 likes
df = df[df['Likes'] >= 10]
# Print the number of tweets
print('Number of tweets: ' + str(df.shape[0]))
Number of tweets: 3185
import plotly.express as px
import plotly.io as pio
pio.renderers.default='notebook'
# Clean up the data
df['Tweet'] = [i.split('http')[0] for i in df['Tweet']]
df['Tweet'] = df['Tweet'].str.wrap(30)
df['Tweet'] = df['Tweet'].apply(lambda x: x.replace('\n', '<br>'))
# Plot
fig = px.scatter(df, x="Likes", y="Retweets", hover_data=['User', 'Tweet', 'Date'], log_x=True, log_y=True, opacity=0.5, title='Likes vs. Retweets')
fig.show()